package com.yxx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxx.entity.Comment;
import com.yxx.entityModel.vo.query.CommentQuery;
import com.yxx.entityModel.vo.response.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author yuxiangxun
 * @date 2025/2/6
 * @apiNote
 */
@Repository
public interface CommentMapper extends BaseMapper<Comment> {
    /**
     * 查询后台评论数量
     * @param commentQuery
     * @return
     */
    Long countComment(@Param("param") CommentQuery commentQuery);

    /**
     * 分页查询后台评论列表
      * @param commentQuery
     * @return
     */
    List<CommentBackResponse> selectCommentBackList(@Param("param") CommentQuery commentQuery);

    /**
     * 查看最新评论
     * @return
     */
    List<RecentCommentResponse> selectRecentComment();

    /**
     * 分页查询父评论
     * @param commentQuery 查询条件
     * @return List<CommentResponse> 评论集合
     */
    List<CommentResponse> selectParentComment(@Param("param") CommentQuery commentQuery);

    /**
     * 查询每条父评论下的前三条子评论
     * @param parentCommentIdList 父评论id集合
     * @return 回复评论
     */
    List<ReplyResponse> selectReplyByParentCommentIdList(@Param("parentCommentIdList") List<Integer> parentCommentIdList);

    /**
     * 根据父评论id查询回复数量
     * @param parentCommentIdList
     * @return
     */
    List<ReplyCountResponse> selectReplyCountByParentId(@Param("parentCommentIdList") List<Integer> parentCommentIdList);

    /**
     * 根据父评论id查询子评论id
     * @param parentId
     * @return
     */
    List<Integer> selectCommentIdByParentId(@Param("parentId") Integer parentId);

    /**
     * 查询父评论下的子评论
     * @param limit
     * @param size
     * @param commentId
     * @return
     */
    List<ReplyResponse> selectReplyByParentId(@Param("limit") Long limit, @Param("size") Long size, @Param("commentId") Integer commentId);

    /**
     * 根据评论类型id获取评论量
     * @param talkIdList
     * @param commentType
     * @return
     */
    List<CommentCountResponse> selectCommentCountByTypeId(@Param("typeIdList")List<Integer> talkIdList, @Param("commentType") Integer commentType);
}
